package com.china08.yxyapi.api.manage.sch.platform.website.image;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.entity.db.sws.SwsSettingSliders;
import com.china08.yxyapi.model.YxyApiPageReqModel;
import com.china08.yxyapi.model.YxyApiRespModel;
import com.china08.yxyapi.repository.db.SwsSettingSlidersRepository;

@CrossOrigin
@RestController("ImageDelController")
public class ImageDelController {

    @Autowired
    SwsSettingSlidersRepository swsSettingSlidersRepository;

    @RequestMapping(value = "/api_yw/manage/sch/platform/website/image/del", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Object precess(HttpServletRequest request, HttpServletResponse response, @RequestBody ReqModel reqModel) {
        String id = reqModel.id;
        Assert.isTrue(StringUtils.isNotBlank(id), "未获取删除的焦点图");
        SwsSettingSliders swsSettingSliders = swsSettingSlidersRepository.findById(id);
        Assert.isTrue(null != swsSettingSliders, "未获取删除的焦点图");
        swsSettingSlidersRepository.delete(swsSettingSliders);
        return true;
    }

    protected static class ReqModel extends YxyApiPageReqModel {
        // 焦点图id
        public String id;
    }

    protected static class RespModel extends YxyApiRespModel {
    }
}
